package com.qj.sys.db.service.impl;

import com.qj.sys.db.BackUpDataFactory;
import com.qj.sys.db.BackUpDataHandler;
import com.qj.sys.db.entity.BackUpDataSceneEnum;
import com.qj.sys.db.service.BackUpService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.Objects;

/**
 * @author dlw
 * @date 2025-06-03 11:59
 * @desc 数据归档服务类
 */
@Service
@Slf4j
public class BackUpServiceImpl implements BackUpService {
    @Resource
    private BackUpDataFactory backUpDataFactory;
    @Override
    public void backUp(BackUpDataSceneEnum sceneEnum) {
        log.info("BackUpServiceImpl.backUp.scene:{}!", sceneEnum.getCode());
        BackUpDataHandler backUpDataHandler = backUpDataFactory.getHandlerByCode(sceneEnum.getCode());
        if (Objects.isNull(backUpDataHandler)) {
            log.info("BackUpServiceImpl.noFindScene!");
            return;
        }
        backUpDataHandler.backUpData();
    }
}
